#include "Instance.h"

const char *Instance::EXT = ".mli";
const char *Instance::DIR = "instances";

Instance::Instance() {
	name = NULL;
	ready = false;
}

Instance::~Instance() {
	if (name != NULL)
		delete [] name;
}

bool Instance::load( const char *name, Problem *problem ) throw (NotFound) {
	this->problem = problem;
	this->name = Util::copyArray( name, strlen(name) + 1 );
	return true;
}

char* Instance::getPath() throw (NotReady) {
	char *path = new char[ strlen(name) + strlen(DIR) + strlen(EXT) + 1];
	sprintf(path, "%s/%s/%s%s", DIR, problem->getName(), name, EXT);
	return path;
}